namespace Pp.Core.File
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;

    public class FileReader
    {
        public string fileString;
        public FileReader(string path)
        {
            var fs = new FileStream(path, FileMode.Open, FileAccess.Read);
            var r = new StreamReader(fs, Encoding.Default);
            fileString = r.ReadToEnd();
        }
        public string GetMailTemplate(params KeyValuePair<string, string>[] keyValuePairs)
        {
            return keyValuePairs.Aggregate(fileString, (current, keyValuePair) => current.Replace("#" + keyValuePair.Key + "#", keyValuePair.Value));
        }

        public string GetMailTemplat(IList<MailModel> keyValuePairs)
        {
            return keyValuePairs.Aggregate(fileString, (current, keyValuePair) => current.Replace("#" + keyValuePair.Key + "#", keyValuePair.Value));
        }
    }
}